﻿<?xml version="1.0" encoding="UTF-8"?>

<!--=============================================================
    File: nav.xslt                                                   
    Created by: sitecore\ashkiel                                       
    Created: 7/23/2010 4:36:55 PM                                               
    Copyright notice at bottom of file
==============================================================-->

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:sc="http://www.sitecore.net/sc"
  xmlns:dot="http://www.sitecore.net/dot"
  exclude-result-prefixes="dot sc">

  <!-- output directives -->
  <xsl:output method="html" indent="no" encoding="UTF-8" />

  <!-- parameters -->
  <xsl:param name="lang" select="'en'"/>
  <xsl:param name="id" select="''"/>
  <xsl:param name="sc_item"/>
  <xsl:param name="sc_currentitem"/>

  <!-- variables -->
  <!-- Uncomment one of the following lines if you need a "home" variable in you code -->
  <xsl:variable name="home" select="sc:item('/sitecore/content/EFI/Connect',.)" />
  <!--<xsl:variable name="home" select="/*/item[@key='content']/item[@key='home']" />-->
  <!--<xsl:variable name="home" select="$sc_currentitem/ancestor-or-self::item[@template='site root']" />-->


  <!-- entry point -->
  <xsl:template match="*">
    <xsl:apply-templates select="$sc_item" mode="main"/>
  </xsl:template>

  <!--==============================================================-->
  <!-- main                                                         -->
  <!--==============================================================-->
  <xsl:template match="*" mode="main">
    <xsl:choose>
      <xsl:when test="sc:fld('Top Image',.)=''">
        <sc:image field="Top Image" select=".."/>
      </xsl:when>
      <xsl:otherwise>
        <sc:image field="Top Image"/>
      </xsl:otherwise>
    </xsl:choose>

    <ul class="nav">
      <xsl:for-each select="$home/item">
        <xsl:if test="sc:fld('Dont Show In Nav',.) != '1'">
          <!-- First level -->
          <xsl:element name="li">
            <xsl:attribute name="class">
              <xsl:if test="./item">hasChildren </xsl:if>
              <xsl:if test="$sc_currentitem/self::item/@id = @id">selected open </xsl:if>
              <xsl:if test="$sc_currentitem/ancestor::item/@id = @id">open </xsl:if>
              <xsl:if test="position() = last()">last</xsl:if>
            </xsl:attribute>
            <sc:link>
              <span>
                <sc:text field="Nav Title" />
              </span>
            </sc:link>
            <xsl:if test="./item">
              <ul>
                <xsl:for-each select="./item">
                  <!-- Second Level -->
                  <xsl:if test="sc:fld('Dont Show in Nav',.)='' or (sc:fld('Dont Show in Nav',.)!='' and sc:fld('Show in LeftNav',.)!='')">
                    <xsl:element name="li">
                      <xsl:attribute name="class">
                        <xsl:if test="./item">hasChildren </xsl:if>
                        <xsl:if test="$sc_currentitem/self::item/@id = @id">selected open </xsl:if>
                        <xsl:if test="$sc_currentitem/ancestor::item/@id = @id">open </xsl:if>
                        <xsl:if test="position() = last()">last</xsl:if>
                      </xsl:attribute>
                      <xsl:choose>
                        <xsl:when test="sc:fld('External Link',.)!=''">
                          <sc:link field="External Link">
                            <span>
                              <sc:text field="Nav Title" />
                            </span>
                          </sc:link>
                        </xsl:when>
                        <xsl:otherwise>
                          <sc:link>
                            <span>
                              <sc:text field="Nav Title" />
                            </span>
                          </sc:link>
                        </xsl:otherwise>
                      </xsl:choose>
                    </xsl:element>
                  </xsl:if>
                </xsl:for-each>
              </ul>
            </xsl:if>
          </xsl:element>
        </xsl:if>
      </xsl:for-each>

    </ul>
    
    <hr class="double"/>
    <xsl:if test="sc:fld('Left Column Section Title',.)!=''">
      <h5>
        <sc:text field="Left Column Section Title"/>
      </h5>
    </xsl:if>
    <xsl:if test="sc:fld('Left Column Image',.)!=''">
      <sc:image field="Left Column Image"/>
    </xsl:if>
    <xsl:if test="sc:fld('Left Column Section Text',.)!=''">
      <sc:html field="Left Column Section Text"/>
      <hr class="double"/>
    </xsl:if>
    <xsl:if test="sc:fld('Left Column Section Title',.)='' and sc:fld('Left Column Section Title',..)!=''">
      <h5>
        <sc:text field="Left Column Section Title" select=".."/>
      </h5>
    </xsl:if>
    <xsl:if test="sc:fld('Left Column Image',.)='' and sc:fld('Left Column Image',..)!=''">
      <sc:image field="Left Column Image" select=".."/>
    </xsl:if>
    <xsl:if test="sc:fld('Left Column Section Text',.)='' and sc:fld('Left Column Section Text',..)!=''">
      <sc:html field="Left Column Section Text" select=".."/>
      <hr class="double what"/>
    </xsl:if>

  </xsl:template>

</xsl:stylesheet>